﻿using System.Net.Sockets; 
using System.Text; 

class LicenseAdmin
{
    static void Main(string[] args)
    {
        Console.WriteLine("请输入用户名：");
        string username = Console.ReadLine(); 
      
        Console.WriteLine("请输入口令：");
        string password = Console.ReadLine();

        
        Console.WriteLine("请输入许可证类型（用户数量）：");
        int maxUsers = int.Parse(Console.ReadLine());
        
        string request = $"GENERATE:{maxUsers}";
        
        string response = SendRequest(request);
        
        Console.WriteLine($"服务器响应：{response}");
    }

    // 发送请求到服务器的函数
    static string SendRequest(string request)
    {
        using (var client = new TcpClient("127.0.0.1", 8080)) // 连接到服务器
        {
            NetworkStream stream = client.GetStream();
            byte[] requestData = Encoding.UTF8.GetBytes(request);
            stream.Write(requestData, 0, requestData.Length);
            byte[] responseData = new byte[256];
            int bytesRead = stream.Read(responseData, 0, responseData.Length);
            
            return Encoding.UTF8.GetString(responseData, 0, bytesRead);
        } 
    }
}